program main

    use load_pif_m, only: load_pif
    use linked_list_nnps_m, only: build => build_list_from_loc, query
    use list_type_m, only: list_t
    use twin_list_type_m, only: twin_list_t
    implicit none
    real, allocatable :: loc(:, :)
    type(list_t), allocatable :: list(:, :)
    type(twin_list_t) :: twin_list

    call load_pif("example/ini_xv.dat", loc)
    call build(loc, 2.5000000E-01, 2, list)
    ! print *, list(2, 1)%items, list(2, 1)%log

    call query(loc, list, 3.0000000E-01, 50, twin_list) !@note: 半径

    print "(A,I0)", "> 交互粒子对数目: ", twin_list%log
    print "(A)", "> i 数组"
    print "(g0)", twin_list%items(1, :twin_list%log)
    print "(A)", "> j 数组"
    print "(g0)", twin_list%items(2, :twin_list%log)

    ! do i = 1, 4
    !     do j = 1, 4
    !         print *, list(i, j)%items(1:list(i, j)%log), list(i, j)%log
    !     end do
    ! end do

end program main

! 4  8  12  16
! 3  7  11  15
! 2  6  10  14
! 1  5   9  13
